package cn.ito.zjgsu.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.github.pagehelper.PageHelper;

import cn.ito.zjgsu.constant.StatusCode;
import cn.ito.zjgsu.domain.IndustryType;
import cn.ito.zjgsu.domain.IndustryTypeExample;
import cn.ito.zjgsu.domain.wrapper.IndustryTypeWrapper;
import cn.ito.zjgsu.mapping.IndustryTypeMapper;
import cn.ito.zjgsu.service.IndustryTypeService;
@Service
@Transactional
public class IndustryTypeServiceImpl implements IndustryTypeService{

	@Resource
	private IndustryTypeMapper industryTypeMapper;
	
	//C-----------------------------------------------------------------------------------------------
		@Override
		public String insertList(List<IndustryType> its) {
			String status = StatusCode.FAILURE_STATUS;
			try {
				industryTypeMapper.insertList(its);
				status = StatusCode.SUCCESS_STATUS;
			} catch (Exception e) {
				e.printStackTrace();
				status = StatusCode.FAILURE_STATUS;
			}
			return status;
		}
	
	
	//R----------------------------------------------------------------------------------------------
	@Override
	public List<IndustryType> queryByPage(int pageNum, int records) {
		IndustryTypeExample industryTypeExample = new IndustryTypeExample();
		industryTypeExample.or().andItDeleteTagsEqualTo(IndustryTypeWrapper.INDUSTRYTYPE_EXIST_FLAG);
		PageHelper.startPage(pageNum, records);
		List<IndustryType> industryTypes = industryTypeMapper.selectByExample(industryTypeExample);
		return industryTypes;
	}

	
	//U-----------------------------------------------------------------------------------------------------
	@Override
	public String updateByIndustryTypeExample(IndustryType industryType, IndustryTypeExample industryTypeExample) {
		String status = StatusCode.FAILURE_STATUS;
		try {
			industryTypeMapper.updateByExampleSelective(industryType, industryTypeExample);
			status = StatusCode.SUCCESS_STATUS;
		} catch (Exception e) {
			e.printStackTrace();
			status = StatusCode.FAILURE_STATUS;
		}
		return status;
	}

	
	
	
	
	//D-----------------------------------------------------------------------------------------------------
	@Override
	public String deleteIndustryByExample(IndustryTypeExample industryTypeExample) {
		String status = StatusCode.FAILURE_STATUS;
		try {
			IndustryType industryType = new IndustryType();
			industryType.setItDeleteTags(false);
			industryTypeMapper.updateByExampleSelective(industryType, industryTypeExample);
			status = StatusCode.SUCCESS_STATUS;
		} catch (Exception e) {
			e.printStackTrace();
			status = StatusCode.FAILURE_STATUS;
		}
		return status;
	}


	
}
